package com.yueyang.sojourn.server.model.dto;

import com.yueyang.sojourn.server.model.enums.JumpTypeEnum;
import com.yueyang.sojourn.server.validation.annotation.EnumValid;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.util.Date;

/**
 * @author yemingxing
 * @summary
 * @Copyright (c) 2020, Yueyang Group All Rights Reserved.
 * @since 2020-02-26
 */
@Data
@ToString
@ApiModel("编辑BannerDTO")
public class EditBannerDto {

    @ApiModelProperty(value = "主键id", required = true)
    @NotNull(message = "[Banner id]不能为空")
    private Long id;

    /**
     * 展示时间开始
     */
    @ApiModelProperty(value = "展示时间开始,格式：yyyy-MM-dd HH:mm:ss", example = "2020-02-20 00:00:00", required = true, dataType = "string")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date showTimeBegin;

    /**
     * 展示时间结束
     */
    @ApiModelProperty(value = "展示时间结束,格式：yyyy-MM-dd HH:mm:ss", example = "2020-03-02 00:00:00", required = true, dataType = "string")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Future(message = "[展示时间结束]请选择未来的某个时刻")
    private Date showTimeEnd;

    /**
     * 标题
     */
    @ApiModelProperty(value = "展位标题", required = true)
    @Size(max = 20, message = "[展位标题]最大支持20个字")
    private String title;

    /**
     * 排序值，越大越靠前
     */
    @ApiModelProperty(value = "展位排序，值越大越靠前", required = true)
    @NotNull(message = "[展位排序]不能为空")
    @Min(value = 1, message = "[展位排序]仅支持输入1~99的正整数")
    @Max(value = 99, message = "[展位排序]仅支持输入1~99的正整数")
    private Integer sort;

    /**
     * banner图片
     */
    @ApiModelProperty(value = "展位图片", required = true)
    @Valid
    private AttachDto pic;

    /**
     * 点击跳转类型
     */
    @ApiModelProperty(value = "跳转类型(枚举值)", required = true)
    @EnumValid(clazz = JumpTypeEnum.class, message = "[跳转类型]枚举值错误")
    private Integer jumpType;

    /**
     * 跳转值
     */
    @ApiModelProperty(value = "跳转类型对应值", required = true)
    @Size(max = 200, message = "[跳转类型对应值]最大支持200长度")
    private String jumpVal;
}